<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <h:body>
        <ui:composition template="../WEB-INF/template_admin.xhtml">
            <ui:define name="title">
                <h:outputText value="#{bundle.ListCategoriaTitle}"></h:outputText>
            </ui:define>
            <ui:define name="content">
                <div class="content">
                    <br />
                    <ul class="lista-mapa-sitio">
                        <li><a href="#{request.contextPath}/faces/administrador.xhtml">Administrar</a> / </li>
                        <li>Categorias</li>
                    </ul>
                    <p:fieldset legend="Lista de Categorías" style="width: 700px" styleClass="panel-usuario">
                        <div class="divcategoria">
                            <p:growl id="growl"/>

                            <h:form styleClass="jsfcrud_list_form">
                                <h:panelGroup id="messagePanel" layout="block">
                                    <p:messages autoUpdate="true"/>
                                </h:panelGroup>
                                <h:outputText escape="false" value="#{bundle.ListCategoriaEmpty}" rendered="#{categoriaController.items.rowCount == 0}"/>
                                <h:panelGroup styleClass="jsfcrud_list_panelgroup" rendered="#{categoriaController.items.rowCount > 0}">
                                    <p:dataTable id="tbl" value="#{categoriaController.items}" var="item" emptyMessage="No se encontraron categorías con ese criterio"
                                                 widgetVar="userTable" paginator="true" rows="5" 
                                                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                                 rowsPerPageTemplate="5,10,20">
                                        <p:column>
                                            <f:facet name="header">
                                                <h:outputText value="&nbsp;"/>
                                            </f:facet>
                                            <h:commandLink action="#{categoriaController.prepareEdit}" title="#{bundle.ListCategoriaEditLink}">
                                                <img src="../images/b_edit.png" width="16" height="16" alt="b_edit"/>
                                            </h:commandLink>
                                            <p:commandLink title="#{bundle.ListCategoriaDestroyLink}" update=":growl" onclick="cd.show()">
                                                <img src="../images/b_drop.png" width="16" height="16" alt="b_drop"/>
                                            </p:commandLink>
                                            <p:confirmDialog message="¿Está seguro de querer eliminar el registro?"
                                                             header="Iniciando proceso de eliminación" severity="alert"
                                                             widgetVar="cd">
                                                <p:commandButton value="Si" actionListener="#{categoriaController.destroy}"
                                                                 update=":growl" oncomplete="cd.hide()"/>
                                                <p:commandButton value="No" onclick="cd.hide();" type="button" />
                                            </p:confirmDialog>
                                        </p:column>
                                        <p:column filterBy="#{item.catNombre}" sortBy="#{item.catNombre}">
                                            <f:facet name="header">
                                                <h:outputText value="#{bundle.ListCategoriaTitle_nombre}"/>
                                            </f:facet>
                                            <h:outputText value="#{item.catNombre}"/>
                                        </p:column>
                                        <p:column filterBy="#{item.catSize}" sortBy="#{item.catSize}">
                                            <f:facet name="header">
                                                <h:outputText value="#{bundle.ListCategoriaTitle_tamano}"/>
                                            </f:facet>
                                            <h:outputText value="#{item.catSize}"/>
                                        </p:column>
                                        <p:column filterBy="#{item.catPrecio}" sortBy="#{item.catSize}">
                                            <f:facet name="header">
                                                <h:outputText value="#{bundle.ListCategoriaTitle_precio}"/>
                                            </f:facet>
                                            <h:outputText value="$ #{item.catPrecio}"/>
                                        </p:column>
                                    </p:dataTable>

                                    <br />
                                    <h:commandLink styleClass="jsfcrud_commandlinks_action" action="#{categoriaController.prepareCreate}" value="#{bundle.ListCategoriaCreateLink}" style="margin-left: 25px"/>
                                    <br />
                                    <h:panelGrid columns="2">  
                                        <p:panel header="Exportar Todo">  
                                            <h:commandLink>  
                                                <p:graphicImage value="../images/excel.png" />  
                                                <p:dataExporter type="xls" target="tbl" fileName="categorias" excludeColumns="0" postProcessor="#{exporterBean.postProcessXLS}"/>  
                                            </h:commandLink>  
                                            <h:commandLink>  
                                                <p:graphicImage value="../images/pdf.png" />  
                                                <p:dataExporter type="pdf" target="tbl" fileName="categorias" excludeColumns="0" preProcessor="#{exporterBean.preProcessPDF}"/>  
                                            </h:commandLink>  
                                            <h:commandLink>  
                                                <p:graphicImage value="../images/csv.png" />  
                                                <p:dataExporter type="csv" target="tbl" fileName="categorias" excludeColumns="0" />  
                                            </h:commandLink>  
                                        </p:panel>  

                                        <p:panel header="Exportar Página">  
                                            <h:commandLink>  
                                                <p:graphicImage value="../images/excel.png" />  
                                                <p:dataExporter type="xls" target="tbl" fileName="categorias" pageOnly="true" excludeColumns="0" postProcessor="#{exporterBean.postProcessXLS}" />  
                                            </h:commandLink>  
                                            <h:commandLink>  
                                                <p:graphicImage value="../images/pdf.png" />  
                                                <p:dataExporter type="pdf" target="tbl" fileName="categorias" pageOnly="true" excludeColumns="0" preProcessor="#{exporterBean.preProcessPDF}"/>  
                                            </h:commandLink>  
                                            <h:commandLink>  
                                                <p:graphicImage value="../images/csv.png" />  
                                                <p:dataExporter type="csv" target="tbl" fileName="categorias" pageOnly="true" excludeColumns="0"/>  
                                            </h:commandLink>  
                                        </p:panel>  
                                    </h:panelGrid>
                                </h:panelGroup>
                            </h:form>
                        </div><!-- end of divcategoria -->
                        <div style="height: 30px" class="cleaner_h5"></div>
                    </p:fieldset>
                    <br/>
                </div><!-- end of content -->
            </ui:define>
        </ui:composition>
    </h:body>
</html>
